//
//  NewMyErWeiMaViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/3/15.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewMyErWeiMaViewController.h"
#import "JTCSM.h"
#import "TypeView.h"
#import "HomePageModel.h"
@interface NewMyErWeiMaViewController ()<UINavigationControllerDelegate>
{
    UIImageView *headerImageView;
}
@property (nonatomic,strong) UIImageView *logoImageV;
@property (nonatomic,strong) UIImageView *erweimaImageV;
@property (nonatomic,strong) UILabel *nameLable;
@property (nonatomic,strong) UILabel *contentLabel;
@end

@implementation NewMyErWeiMaViewController

- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}
// 将要显示控制器
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 判断要显示的控制器是否是自己
    BOOL isShowHomePage = [viewController isKindOfClass:[self class]];
    [self.navigationController setNavigationBarHidden:isShowHomePage animated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    self.navigationController.delegate = self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [df isRemoveTarbar:YES];
    self.view.backgroundColor = KZhuTiRGB;
    
//    1.1825;
    CGFloat headerSpace = 40*[JTCSMSingle shareSingle].adaptationNumber;
    CGFloat headerImageWidth = KCONTROLLERWith-headerSpace*2;
    CGFloat headerIamgeHeight = headerImageWidth*1.1825;
    headerImageView = [[UIImageView alloc]initWithFrame:CGRectMake(headerSpace, 88, headerImageWidth, headerIamgeHeight)];
    headerImageView.image = [UIImage imageNamed:@"我的二维码_背景.png"];
    [self.view addSubview:headerImageView];
    UIImage * firstImage = [UIImage imageNamed:@"fanhui.png"];
    CGRect firstFrame = CGRectMake(20, 20, 50, 44);
    CGFloat width = firstFrame.size.width;
    CGFloat height = firstFrame.size.height;
    CGFloat imagesize = 20;
    UIButton * leftButton = [[UIButton alloc]initWithFrame:firstFrame];
    [leftButton setImage:firstImage forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(gotBack) forControlEvents:UIControlEventTouchUpInside];
    leftButton.imageEdgeInsets = UIEdgeInsetsMake((height-imagesize)/2, 0, (height-imagesize)/2, (width-imagesize));
    [self.view addSubview:leftButton];
    UILabel *titleLabel = [UILabel initWithFrame:CGRectMake(0, 20, KCONTROLLERWith, 44) text:@"身份认证" font:20 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(51, 51, 51, 1) backgroundColor:nil];
    [self.view addSubview:titleLabel];
    
    CGFloat changetop = headerIamgeHeight/98;
    CGFloat top = 10;
    CGFloat space = headerImageWidth*3/232;
    CGFloat headerHight = headerIamgeHeight*268/1160;
    
    CGFloat logoImageVSize = (headerHight-2*top);
    self.logoImageV = [[UIImageView alloc]initWithFrame:CGRectMake(15+space, top+changetop, logoImageVSize, logoImageVSize)];
    self.logoImageV.image = [UIImage imageNamed:@"个人信息_头像.png"];
    [headerImageView addSubview:self.logoImageV];
    CGRect myrect = [df labelHeightWithContent:@"测试数据" width:2000 font:15];
    CGFloat labelheight = myrect.size.height;
    CGFloat changespace = (logoImageVSize-2*labelheight)>10?10:(logoImageVSize-2*labelheight);
    self.nameLable = [UILabel initWithFrame:CGRectMake(KVIEW_X(_logoImageV)+10, self.logoImageV.LC_x, headerImageView.LC_width, labelheight) text:@"一点惊喜" font:15 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(51, 51, 51, 1) backgroundColor:nil];
    [headerImageView addSubview:self.nameLable];
    self.contentLabel = [UILabel initWithFrame:CGRectMake(KVIEW_X(_logoImageV)+10, self.logoImageV.LC_x+labelheight+changespace-3, headerImageView.LC_width, labelheight) text:@"快告诉小伙伴，我在用爱码付" font:12 textAlignment:NSTextAlignmentLeft texcolor:[df colorWithHexString:@"666666" alpha:1] backgroundColor:nil];
    [headerImageView addSubview:self.contentLabel];
    [df newlineViewWithHeightofTop:headerHight+changetop superView:headerImageView spacing:20 color:RGBACOLOR(241, 241, 241, 1) lineHeight:1];
    
    CGFloat erweimaSpace = 40;
    CGFloat erweimaSize = headerImageView.LC_height-2*top-headerHight-2*erweimaSpace;
    self.erweimaImageV = [[UIImageView alloc]initWithFrame:CGRectMake((headerImageView.LC_width-erweimaSize)/2, headerHight+top+erweimaSpace, erweimaSize, erweimaSize)];
    self.erweimaImageV.image = [UIImage imageNamed:@"erweima.jpg"];
    [headerImageView addSubview:self.erweimaImageV];
    CGFloat shareTypeheight = headerImageView.LC_width*0.0556;
    UIImageView *shareTypeImageV = [[UIImageView alloc]initWithFrame:CGRectMake(headerSpace, KVIEW_Y(headerImageView)+34, headerImageView.LC_width, shareTypeheight)];
    shareTypeImageV.image = [UIImage imageNamed:@"我的二维码_分享方式.png"];
    [self.view addSubview:shareTypeImageV];
    
    TypeView *view;
    NSArray *titleArray = @[@"微信",@"朋友圈",@"QQ",@"QQ空间"];
    NSArray *imageArray = @[@"我的二维码_微信.png",@"我的二维码_朋友圈.png",@"我的二维码_QQ.png",@"我的二维码_空间.png"];
    NSMutableArray *typearray = [NSMutableArray arrayWithCapacity:2];
    for (int i = 0; i <titleArray.count; i++) {
        HomePageModel *model = [[HomePageModel alloc]init];
        model.titleStr = titleArray[i];
        model.imagename = imageArray[i];
        [typearray addObject:model];
    }
    CGFloat spaceofLeft = 25*[JTCSMSingle shareSingle].adaptationNumber;
    CGFloat typeviewSize = (KCONTROLLERWith-5*spaceofLeft)/4;
    for (int i = 0 ; i<typearray.count; i++) {
        
        view= [[TypeView alloc]initWithFrame:CGRectMake(spaceofLeft+(typeviewSize+spaceofLeft)*i,KVIEW_Y(shareTypeImageV)+20, typeviewSize, typeviewSize) TypeViewType:headerType];
        HomePageModel *model = typearray[i];
        [view setvalueWithModel:model];
        view.tag = 2000+i;
        view.userInteractionEnabled = YES;
        [df addTapGestureRecognizerWithTarget:self action:@selector(ssharehare:) andaddView:view];
        [self.view addSubview:view];
    }
    NSString *alertLabelStr = @"分享推广码";
    CGRect rect = [df labelHeightWithContent:alertLabelStr width:1000 font:12];
    
    UILabel *alertLabel = [UILabel initWithFrame:CGRectMake((KCONTROLLERWith-rect.size.width)/2, KCONTROLLERHeight-56*[JTCSMSingle shareSingle].adaptationNumber, rect.size.width, rect.size.height+2) text:alertLabelStr font:12 textAlignment:NSTextAlignmentCenter texcolor:[df colorWithHexString:@"6d5805" alpha:1] backgroundColor:nil];
    [self.view addSubview:alertLabel];
    [df lineViewWithHeightofTop:rect.size.height+2 superView:alertLabel spacing:0 color:[df colorWithHexString:@"6d5805" alpha:1] lineHeight:1];
}
- (void)ssharehare:(UITapGestureRecognizer *)tap{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
